package com.hellpro.lolbox.factory;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.SparseArray;

import com.hellpro.lolbox.config.UrlConfigs;
import com.hellpro.lolbox.home.weight.ZXCommAFragment;
import com.hellpro.lolbox.home.weight.ZXCommAFragmentB;
import com.hellpro.lolbox.home.weight.ZXCommAFragmentC;
import com.hellpro.lolbox.home.weight.ZXCommBFragment;

/**
 * Package_Name: com.hellpro.lolbox.video
 * Description :Fragment倒错包了，可以简化为一个方法。。就这样啦。。。可以致谢一个new
 * author: HellPermanent
 * date:  2016/10/21 9:44
 * remarks：
 */
public class ZXFragmentFactory {
    //标记是A还是B类型
    //A类型

    private static final  int TT =0;
    private static final  int SP=1;
    private static final  int SS=2;
    private static final  int LZ=3;
    private static final  int JT=4;
    private static final  int BZ=5;
    //SparseArray:key整形
    private static SparseArray<Fragment> fragmentASparseArray =new SparseArray<>();

//创建工厂生产对象
    public static Fragment creatAFragment(int  aNum){

            Fragment fragment = fragmentASparseArray.get(aNum);
            if (fragment== null){
                switch (aNum){
                    case TT:
                        fragment= new  ZXCommAFragment();
                        fragmentASparseArray.put(TT,fragment);
                        break;
                    case SP:
                        fragment = new ZXCommAFragmentB();
                        fragmentASparseArray.put(SP,fragment);
                        break;
                    case SS:
                        fragment = new ZXCommAFragmentC();
                        fragmentASparseArray.put(SS,fragment);
                        break;
                        case LZ:
                            fragment = new ZXCommBFragment();
                            fragmentASparseArray.put(LZ,fragment);
                            Bundle bundle = new Bundle();
                            bundle.putString("path",UrlConfigs.ZXLZ);
                            fragment.setArguments(bundle);
                            break;

                    case JT:
                        fragment = new ZXCommBFragment();
                        Bundle bundle1 = new Bundle();
                         bundle1.putString("path",UrlConfigs.ZXJT);
                        fragment.setArguments(bundle1);
                        fragmentASparseArray.put(JT,fragment);
                        break;
                    case BZ:
                        fragment = new ZXCommBFragment();
                        Bundle bundle3 = new Bundle();
                        bundle3.putString("path",UrlConfigs.ZXBZ);
                        fragment.setArguments(bundle3);
                        fragmentASparseArray.put(BZ,fragment);
                        break;

                }
            }
        return fragment;

    }


}
